package svc

import (
	"github.com/zeromicro/go-zero/core/stores/cache"
	"listenboos-common/db"
	"ucenter/internal/config"
	"ucenter/internal/database"
)

type ServiceContext struct {
	Config      config.Config
	Cache       cache.Cache
	DB          *db.ListenDB
	MongoClient *database.MongoClient
}

func NewServiceContext(c config.Config) *ServiceContext {
	redisCache := cache.New(c.CacheRedis, nil,
		cache.NewStat("listenbooks"), nil, func(o *cache.Options) {})
	return &ServiceContext{
		Config:      c,
		Cache:       redisCache,
		DB:          database.ConnMysql(c.Mysql.DataSource),
		MongoClient: database.ConnectMongo(c.Mongo),
	}
}
